module crest_testmol
!> coffeine
  use iso_fortran_env,only:wp => real64
  use strucrd
  implicit none
  private

  public :: get_testmol

!&<
  integer,parameter ::  caffeine_nat = 24
  integer, parameter :: caffeine_at(caffeine_nat) = [6,7,6,7,6,6,6,8,7,6,8,7,6,6, &
  &                                        1,1,1,1,1,1,1,1,1,1]
  real(wp),parameter :: caffeine_xyz(3,caffeine_nat) =    reshape(&
    &[ 2.02799738646442_wp,  0.09231312124713_wp, -0.14310895950963_wp, &
    &  4.75011007621000_wp,  0.02373496014051_wp, -0.14324124033844_wp, &
    &  6.33434307654413_wp,  2.07098865582721_wp, -0.14235306905930_wp, &
    &  8.72860718071825_wp,  1.38002919517619_wp, -0.14265542523943_wp, &
    &  8.65318821103610_wp, -1.19324866489847_wp, -0.14231527453678_wp, &
    &  6.23857175648671_wp, -2.08353643730276_wp, -0.14218299370797_wp, &
    &  5.63266886875962_wp, -4.69950321056008_wp, -0.13940509630299_wp, &
    &  3.44931709749015_wp, -5.48092386085491_wp, -0.14318454855466_wp, &
    &  7.77508917214346_wp, -6.24427872938674_wp, -0.13107140408805_wp, &
    & 10.30229550927022_wp, -5.39739796609292_wp, -0.13672168520430_wp, &
    & 12.07410272485492_wp, -6.91573621641911_wp, -0.13666499342053_wp, &
    & 10.70038521493902_wp, -2.79078533715849_wp, -0.14148379504141_wp, &
    & 13.24597858727017_wp, -1.76969072232377_wp, -0.14218299370797_wp, &
    &  7.40891694074004_wp, -8.95905928176407_wp, -0.11636933482904_wp, &
    &  1.38702118184179_wp,  2.05575746325296_wp, -0.14178615122154_wp, &
    &  1.34622199478497_wp, -0.86356704498496_wp,  1.55590600570783_wp, &
    &  1.34624089204623_wp, -0.86133716815647_wp, -1.84340893849267_wp, &
    &  5.65596919189118_wp,  4.00172183859480_wp, -0.14131371969009_wp, &
    & 14.67430918222276_wp, -3.26230980007732_wp, -0.14344911021228_wp, &
    & 13.50897177220290_wp, -0.60815166181684_wp,  1.54898960808727_wp, &
    & 13.50780014200488_wp, -0.60614855212345_wp, -1.83214617078268_wp, &
    &  5.41408424778406_wp, -9.49239668625902_wp, -0.11022772492007_wp, &
    &  8.31919801555568_wp, -9.74947502841788_wp,  1.56539243085954_wp, &
    &  8.31511620712388_wp, -9.76854236502758_wp, -1.79108242206824_wp], &
    &  shape(caffeine_xyz))
!&>

!&<
  !> distorted methane
  integer,parameter ::  methane_nat = 5
  integer, parameter :: methane_at(methane_nat) = [6,1,1,1,1]
  real(wp),parameter :: methane_xyz(3,methane_nat) =    reshape(&
    & [-2.901604086313, 2.032342621828, -0.000007558904, &
    &  -4.142827301385, 1.660246889672,  1.875960807537, &
    &  -4.354204487169, 0.990001535591, -1.470244961017, &
    &  -3.376685347364, 4.088767344235, -0.405769514737, &
    &  -1.351217548539, 1.424026988612,  0.000022676711],&
    &  shape(methane_xyz))
!&>


!&<
  !> distorted methane
  integer,parameter ::  cytosine_nat = 13
  integer, parameter :: cytosine_at(cytosine_nat) = [8,6,7,6,6,6,7,7,1,1,1,1,1]
  real(wp),parameter :: cytosine_xyz(3,cytosine_nat) = reshape(&
    & [-4.142195348814,  2.008151058305, -0.018151734373, & 
    &  -2.160173249661,  0.802767457051, -0.000058193762, &  
    &  -2.268542712629, -1.794135272435,  0.003855688769, &
    &  -0.191488773092, -3.309463007997, -0.005095763012, &
    &   2.109332653259, -2.284418067990, -0.007062235327, &
    &   2.185078861327,  0.516677179272,  0.028019148471, &
    &   4.467560431809,  1.727180498582,  0.071380211323, &
    &   0.177657703530,  1.926043596048,  0.012000916144, &
    &  -4.036103295159, -2.521391305153,  0.014335396651, &
    &  -0.507864921184, -5.333664751031, -0.008697813741, &
    &   3.837497023245, -3.367210871956, -0.007065809214, &
    &   5.961039176371,  0.856469245914, -0.742491063662, &
    &   4.318834327087,  3.589804055892, -0.368535366892],&
    &  shape(cytosine_xyz))
!&>

contains

  subroutine get_testmol(name,mol)
    character(len=*),intent(in) :: name
    type(coord),intent(out) :: mol
    select case (name)
    case ('methane')
      mol%nat = methane_nat
      allocate (mol%at(mol%nat))
      mol%at(:) = methane_at(:)
      allocate (mol%xyz(3,mol%nat))
      mol%xyz(:,:) = methane_xyz(:,:)
      mol%chrg = 0
      mol%uhf = 0
    case ('cytosine')
      mol%nat = cytosine_nat
      allocate (mol%at(mol%nat))
      mol%at(:) = cytosine_at(:)
      allocate (mol%xyz(3,mol%nat))
      mol%xyz(:,:) = cytosine_xyz(:,:)
      mol%chrg = 0
      mol%uhf = 0
    case default
      !> caffeine
      mol%nat = caffeine_nat
      allocate (mol%at(mol%nat))
      mol%at(:) = caffeine_at(:)
      allocate (mol%xyz(3,mol%nat))
      mol%xyz(:,:) = caffeine_xyz(:,:)
      mol%chrg = 0
      mol%uhf = 0
    end select
  end subroutine get_testmol

end module crest_testmol
